package com.cj.rabbitmq.controller;

import com.alibaba.fastjson.JSONObject;
import com.cj.common.response.Result;
import com.cj.rabbitmq.service.RabbitMqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @Author cheng jun
 * @Description:
 * @Date 2021/7/11 23:00
 */
@Controller
@RequestMapping(value = "/rabbitMq")
public class RabbitMqController {

    @Autowired
    private RabbitMqService rabbitMqService;

    /**
     * hello模型
     */
    @RequestMapping(value = "/hello", method = RequestMethod.POST)
    @ResponseBody
    public Result hello() {
        rabbitMqService.hello();
        return Result.success(new JSONObject());
    }

    /**
     * work模型
     */
    @RequestMapping(value = "/work", method = RequestMethod.POST)
    @ResponseBody
    public Result work() {
        rabbitMqService.work();
        return Result.success(new JSONObject());
    }

    /**
     * fanout广播模型
     */
    @RequestMapping(value = "/fanout", method = RequestMethod.POST)
    @ResponseBody
    public Result fanout() {
        rabbitMqService.fanout();
        return Result.success(new JSONObject());
    }

    /**
     * route路由模型
     */
    @RequestMapping(value = "/route", method = RequestMethod.POST)
    @ResponseBody
    public Result route() {
        rabbitMqService.route();
        return Result.success(new JSONObject());
    }

    /**
     * topics路由模型
     */
    @RequestMapping(value = "/topics", method = RequestMethod.POST)
    @ResponseBody
    public Result topics(@RequestBody Map<String, Object> map) {
        rabbitMqService.topics(map);
        return Result.success(new JSONObject());
    }
}
